| i=a.count | that is straightforward |
| i=ubound(a) | aha, ubound() is a builtin function that translates to the count method |
| i=ubound a | the parentheses are not necessary in this case |
| CocoaBasic Method Call |
Translation to Objective-C |
|---|---|
| a.count |
[a count] |
| ubound(a) ubound a |
[a count] |
| a.objectForKey("key") a.objectForKey "key" |
[a
objectForKey:@"key"] |
| a.setObject(o,
forKey:"key") a.setObject o, forKey:"key" a.set(Object:o, forKey:"key") a.set Object:o, forKey:"key" a.(setObject:o, forKey:"key") ???? |
[a
setObject:o forKey:@"key"] |
| CocoaBasic Method Call |
Translation to Objective-C |
|---|---|
| NSString.stringWithFormat("fmt") |
[NSString
stringWithFormat:@"fmt"] |
| NSString.stringWithFormat("fmt %@", x) | [NSString stringWithFormat:@"fmt %@", x] |
| NSString.stringWithFormat("fmt %@", value:x) | [NSString stringWithFormat:@"fmt %@", x] |
| Method expects |
CocoaBasic | Translation |
|---|---|---|
| BOOL |
pass expression resulting in
Boolean |
translated to BOOL (integer) |
| int |
pass expression resulting in Integer | |
| long |
pass expression resulting in Integer | |
| float |
pass expression resulting in Single or Double | |
| double |
pass expression resulting in Single or Double | |
| NSPoint |
pass Array [x, y] - x, y are
Single or Double |
two elements are translated to
NSPoint |
| NSRange |
pass Array [location, length] |
two elements are translated to NSRange |
| NSSize |
pass Array [width, height] |
two elements are translated to
NSSize |
| NSRect |
pass nested Array [[x, y],
[width, height] |
four elements are translated to
NSRect |
| id or object of specific class |
pass object |
no translation |
| Level |
Operations |
Description |
|---|---|---|
| 1 |
object |
basic object like variable, string or numeric constant, class constant |
| function(...) | builtin-function call | |
| -a not a len(a) |
operator call | |
| new type(...) | create new instance | |
| (a) | change precedence, i.e. evaluate a first | |
| [a, b, ...] [] |
form array | |
| [ka:a, kb:b, ...] [:] |
form dictionary |
|
| 2 |
object.method(arg,
...) object.method arg, ... |
method call |
| array(index, ...) | get value of array (from object, function result, operator etc.) | |
| 3 |
a^b |
exponential |
| 4 |
a*b a/b a mod b a div b a\b |
multiply and divide |
| 5 |
a+b a-b |
addition and subtraction |
| 6 |
a>b a>=b a<b a<=b a=b a<>b a isa class |
value comparisons check for class membership |
| 7 |
a and b |
logical and |
| 8 |
a or b a xor b |
logical or |
| Symbol |
Operation/Translation |
|---|---|
| app |
access the NSApp object |
| nil |
the nil object |
| self |
the object for which the method
is evaluated |
| super |
the superclass (object) |
| false | evaluates to the Boolean false
value |
| true |
evaluates to the Boolean true
value |
| beep | not yet
implemented |
| quit | not yet implemented |
| userCancelled | not yet implemented |
| Function |
Translation into method call |
|---|---|
| -x |
x.CSchs |
| bitwiseand(a,
b) |
a.CSbitwiseAnd(b) |
| bitwisenot(a) |
a.CSbitwiseNot |
| bitwiseor(a,
b) |
a.CSbitwiseOr(b) |
| bitwisexor(a,
b) |
a.CSbitwiseXor(b) |
| left(s,
n) |
s.left(n) |
| len(s) |
s.length |
| lowercase(s) |
s.lowercaseString |
| mid(s, p) |
s.mid(p) |
| mid(s,
p, n) |
s.mid(p,
length:n) |
| msgbox(s) |
s.msgbox |
| not x |
s.CSnot |
| right(s,
n) |
s.right(n) |
| showurl(s) |
s.showurl |
| ubound(a) |
a.count |
| uppercase(s) |
s.uppercaseString |
| str(a) |
[NSString
stringWithFormat:@"%g", a] |
| val(a) |
s.doubleValue |
| o=new
NSWindow |
o=[[NSWindow
alloc] init] |
| o=new
NSObject(5) |
o=[[NSObject alloc] init:5] |
| o=new
NSWindow(WithWindowRef:12345) |
o=[[NSWindow alloc] initWithWindowRef:12345] |
| o=new
NSDictionary(WithContentsOfFile:"file/path") |
o=[[NSDictionary alloc] initWithContentsOfFile:@"file/path" |
| Area |
case sensitive (i.e. a is not the same as A) |
case insensitive (i.e. a and A are the same) |
|---|---|---|
| keywords (e.g. FOR, NEXT, IF, THEN, AS, END) |
x |
|
| variable names (e.g. a, b, C) |
x |
|
| constant names (e.g. NSStringEncoding) |
x |
|
| method names (initWithData) |
x |
|
| array names (e.g. d(5), E(1,2,3)) |
x |
|
| builtin-function names (e.g. left(x)) |
x |
|
| builtin type names (e.g. double, string) |
x |
|
| operators (not x, new x) |
x |
|
| builtin constants/variables (self, app, super, true, false) |
x |
|
| string constants ("This is a Constant") |
x |
|
| class name constants (e.g. NSString) |
x |
|
| exponent of floating point
numbers (e.g. 1e9) |
x |